<template>
  <div class="carousel">
    <swiper :options="swiperOption">
      <swiper-slide v-for="(item, index) in carousels" :key="index">
        <a href="javascript:;"><img :src="item"></a>
      </swiper-slide>
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
export default {
  data () {
    return {
      swiperOption: {
        pagination: {
          el: '.swiper-pagination',
          clickable: true // 允许点击小圆点跳转
        },
        autoplay: {
          delay: 3000,
          disableOnInteraction: true // 手动切换之后继续自动轮播
        }
      }, // 初始化轮播
      swiperOptionNav: {
        pagination: {
          el: '.swiper-pagination-nav'
        }
      }
    }
  },
  props: {
    carousels: { type: Array }
  }
}
</script>

<style lang="stylus" rel="stylesheet/stylus">
  @import "../../assets/stylus/mixins.styl";
  .carousel
    size(100%, 1.82rem)
    overflow hidden
    span
      &.swiper-pagination-bullet-active
        background #fff
    img
      size(100%, 1.82rem)
</style>
